package com.wmh.baseservice.operationaid.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wmh.baseservice.operationaid.entity.TbStoreData;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;

/**
* @author 谢骏
* @description 针对表【operation_aid_tb_store_data(运营助手-淘宝店铺数据)】的数据库操作Mapper
* @createDate 2023-06-30 15:50:52
* @Entity com.wmh.baseservice.operationAid.entity.TbStoreData
*/
public interface TbStoreDataMapper extends BaseMapper<TbStoreData> {

    default List<String> getStoreOptions(){
        return selectList(new LambdaQueryWrapper<TbStoreData>()
                .groupBy(TbStoreData::getStoreName)
                .orderByDesc(TbStoreData::getCreateTime)
                .select(TbStoreData::getStoreName)
        ).stream().map(TbStoreData::getStoreName).collect(Collectors.toList());
    }

    default List<LocalDateTime> getDataDateOptions(){
        return selectList(new LambdaQueryWrapper<TbStoreData>()
                .groupBy(TbStoreData::getDataDate)
                .orderByDesc(TbStoreData::getDataDate)
                .select(TbStoreData::getDataDate)
        ).stream().map(TbStoreData::getDataDate).collect(Collectors.toList());
    }
}




